#include<stdio.h>
int main() {
	//输入一个有序数列
	int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, k = 0;
	//输入要查找的值
	printf("请输入要查找的值：");
	scanf("%d", &k);
	//开始查找
	int left = 0, right = 9;
	while (left <= right) {
		int r = (left + right) / 2;
		if (k > arr[r]) {
			left = r + 1;
		}
		if (k == arr[r]) {
			printf("找到了，下标为%d", r);
			break;
		}
		if (k < arr[r]) {
			right = r - 1;
		}
	}
	if (left > right)
		printf("找不到，返回-1");
	return 0;
}
